package model.data;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
import java.util.Map.Entry;

public class Result implements Iterable<String> {

	private HashMap<String, String> result;

	public Result() {
		result = new HashMap<String, String>();
	}
	
	public Iterator<String> iterator() {
		TreeMap<String, String> sorted = new TreeMap<String, String>();
		for (Entry<String,String> e : result.entrySet())
			sorted.put(e.getValue(), e.getKey());
		return sorted.keySet().iterator();
	}

	public void put(String ad, String enddate) {
		result.put(ad, enddate);
	}
	
	public String getValueOf(String ad) {
		return result.get(ad);
	}

	public void putAll(HashMap<String, String> items) {
		for (Entry<String,String> entry : items.entrySet()) {
			put(entry.getKey(), entry.getValue());
		}
	}
	
	public String toString() {
		String string = new String();
		for (String ad : result.keySet())
			string += " " + ad;
		return string;
	}
	
	public boolean containsKey(String key) {
		return result.containsKey(key);
	}

	public int size() {
		return result.size();
	}

	public Set<String> keySet() {
		return result.keySet();
	}
}
